home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 18050 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: druid.borland.com!usenet
  2. From: pete@borland.com (Pete Becker)
  3. Newsgroups: comp.os.ms-windows.programmer.tools.misc,comp.os.ms-windows.programmer.win32,comp.os.ms-windows.programmer.misc,comp.lang.c++
  4. Subject: Re: [Q] Why doesn't this compile?
  5. Date: 18 Apr 1996 17:40:01 GMT
  6. Organization: Borland International
  7. Message-ID: <4l5uph$ng9@druid.borland.com>
  8. References: <317523C0.5042@eps.agfa.be> <4l3hlj$6qt@mozo.cc.purdue.edu>
  9. NNTP-Posting-Host: pbecker.borland.com
  10. Mime-Version: 1.0
  11. Content-Type: Text/Plain; charset=ISO-8859-1
  12. X-Newsreader: WinVN 0.99.5
  13.  
  14. In article <4l3hlj$6qt@mozo.cc.purdue.edu>, hillca@cs.purdue.edu says...
  15. >
  16. >In article <317523C0.5042@eps.agfa.be>, rorlic@eps.agfa.be says...
  17. >>test.cpp(18) : error C2352: 'A::L::f' : illegal call of 
  18. >>nonstatic member function
  19. >>Error executing cl.exe.
  20. >>test.obj - 1 error(s), 1 warning(s)
  21. >>
  22. >>------------------------------------------------
  23. >>
  24. >>Anybody knows what's wrong with it?
  25. >>Thanks,
  26. >>
  27. >>-- Ranko.
  28. >
  29. >I think the error message is telling you exactly what is wrong.  You can't 
  30. call 
  31. >A::L::f because it is not a static function.  A static function is shared 
  32. >between all instances of the class (it only has access to other static 
  33. >members), while nonstatic functions all have have access to  the instance 
  34. >specific data of the class. 
  35. >
  36. >A::L::f requires that f is a static function.  Which A object do you expect 
  37. the 
  38. >compiler to call f for?
  39.  
  40. There is no A object involved. B::L is derived from A::L, and the call 
  41. A::L::f() is calling the f() that's defined in A::L. This call is legal. It's 
  42. the compiler that's wrong.
  43.  
  44.